﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/People.Master" Inherits="System.Web.Mvc.ViewPage<PatientTableModel>" %>

<%@ Import Namespace="MedicalManagementSystem.Helpers" %>
<%@ Import Namespace="MedicalManagementSystem.Utils" %>
<%@ Import Namespace="MedicalManagementSystem.Models" %>
<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
    <%=Model.PageDescription %>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainRightColumn" runat="server">
    <h2>
        <%=Model.PageDescription %></h2>
    <p>
        <% Html.RenderPartial("SearchObject"); %>
    </p>
    <div id="DataTableContainer">
        <% Html.RenderPartial("PatientListControl", Model.PaginatedList); %>
    </div>
    <div id="ajax-loading" style="display: none; margin-top: 10px;">
        <%= Html.Image(Url.Content("~/Content/images/ajax-loader.gif"), "Загрузка данных...", null)%><br />
        Загрузка данных...
    </div>
    <script type="text/javascript">
    var searchPattern = null;
    
    $(document).ready(function(){
    $('#doSearch').click(function()
            {
                searchPattern = $('#searchPattern').val();
                getPatientTable(0)
            }
        );
    });
    
    function getPatientTable(page)
    {
        <% var actionUrl = Model.UrlPatientRequest;%>
        if (searchPattern != null && String.IsNullOrEmpty(searchPattern.toString().trim())) return;
        $.ajax({
            url: "<%=actionUrl%>",
            data: "page="+ page +"&searchPattern="+(searchPattern==null?"":searchPattern),
            beforeSend: function(XMLHttpRequest) {
                $('#doSearch').attr("disabled", "disabled");
                $("#ajax-loading").show();
                $('#DataTableContainer').html("");
            },
            success: function(data, textStatus) {
                $('#doSearch').removeAttr("disabled");
                $("#ajax-loading").hide();
                $('#DataTableContainer').html(data);
            },
            type: "POST"
            });
    }
    </script>
</asp:Content>
